/*
 * ContabilidadView.java
 */

package contabilidad;

import com.csvreader.CsvReader;
import java.io.IOException;
import java.sql.SQLException;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileReader;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

/**
 * The application's main frame.
 */
public class ContabilidadView extends FrameView {
    List listaRegistros = new ArrayList();
    private DefaultTableModel modeloTabla= new DefaultTableModel();
    Object [] fila;
    String alumnoUpdate;
    int columnaActual;
    int contador;
    double totalGeneral=0;
    conexion contabilidad = new conexion();



    public ContabilidadView(SingleFrameApplication app) throws SQLException {
        super(app);
        modeloTabla.addColumn("Fecha");
        modeloTabla.addColumn("Transacción");
        //modeloTabla.addColumn("Apellidos");
       // modeloTabla.addColumn("Nombres");
       // modeloTabla.addColumn("Grado");
       // modeloTabla.addColumn("Carrera");
       // modeloTabla.addColumn("Seccion");
        modeloTabla.addColumn("Inscripción");
        modeloTabla.addColumn("GACC");
        modeloTabla.addColumn("Graduación");
        modeloTabla.addColumn("GAIC");
        modeloTabla.addColumn("Colegiatura");
        modeloTabla.addColumn("Computación");
        modeloTabla.addColumn("Inglés");
        modeloTabla.addColumn("Laboratorios");
        modeloTabla.addColumn("Cursos");
        modeloTabla.addColumn("Otros");
        modeloTabla.addColumn("Mora");
        modeloTabla.addColumn("Total");
        modeloTabla.addColumn("Descripción");
        
        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });

            actualizarArbol();
            jButton1.setEnabled(false);
            jButton2.setEnabled(false);
            jButton3.setEnabled(false);
            contador=0;
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ContabilidadApp.getApplication().getMainFrame();
            aboutBox = new ContabilidadAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ContabilidadApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jLabel2 = new javax.swing.JLabel();

        mainPanel.setName("mainPanel"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTree1.setName("jTree1"); // NOI18N
        jScrollPane1.setViewportView(jTree1);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTable1.setModel(modeloTabla);
        jTable1.setName("jTable1"); // NOI18N
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable1);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(contabilidad.ContabilidadApp.class).getContext().getActionMap(ContabilidadView.class, this);
        jButton1.setAction(actionMap.get("Actualizar")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(contabilidad.ContabilidadApp.class).getContext().getResourceMap(ContabilidadView.class);
        jButton1.setIcon(resourceMap.getIcon("StatusBar.busyIcons[0]")); // NOI18N
        jButton1.setText(resourceMap.getString("Actualizar.text")); // NOI18N
        jButton1.setName("Actualizar"); // NOI18N

        jButton2.setAction(actionMap.get("delRow")); // NOI18N
        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton3.setAction(actionMap.get("addRow")); // NOI18N
        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 497, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(jButton2)
                        .addGap(72, 72, 72)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1))))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton2)
                            .addComponent(jButton3)
                            .addComponent(jButton1)
                            .addComponent(jLabel1))))
                .addContainerGap())
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        jMenuItem1.setAction(actionMap.get("parsenadonit")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        fileMenu.add(jMenuItem1);

        jMenuItem3.setAction(actionMap.get("parsenadoTransaccion")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        fileMenu.add(jMenuItem3);

        jMenuItem2.setAction(actionMap.get("cargandonit")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        fileMenu.add(jMenuItem2);

        jMenuItem4.setAction(actionMap.get("cargandotransaccion")); // NOI18N
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        fileMenu.add(jMenuItem4);

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        jMenuItem5.setAction(actionMap.get("parsenadosolvente")); // NOI18N
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        fileMenu.add(jMenuItem5);

        jMenuItem6.setAction(actionMap.get("cargandosolvente")); // NOI18N
        jMenuItem6.setName("jMenuItem6"); // NOI18N
        fileMenu.add(jMenuItem6);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 898, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(statusMessageLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 714, Short.MAX_VALUE))
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel)
                            .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(3, 3, 3))
                    .addComponent(jLabel2)))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // TODO add your handling code here:
        
jButton1.setEnabled(true);
jButton2.setEnabled(true);
jButton3.setEnabled(true);
columnaActual=jTable1.rowAtPoint(evt.getPoint());
       /* for(int i=0;i<modeloTabla.getColumnCount();i++)
            System.out.print(" "+modeloTabla.getValueAt(jTable1.rowAtPoint(evt.getPoint()), i));
        System.out.println("");*/
    }//GEN-LAST:event_jTable1MouseClicked

    @Action
    public void cargandoAsignacion() throws SQLException {
    
    Statement st = contabilidad.getConnection().createStatement();
    Iterator it = listaRegistros.iterator();
    while (it.hasNext())
    {
        asignacion datos = (asignacion) it.next();
        st.executeUpdate("insert into asignacion(ciclo_id,alumno_id,carrera_id,grado_id,seccion_id) "
                + "values("+datos.getciclo()+","+datos.getalumno()
                +",\""+datos.getcarrera()+"\",\""+datos.getgrado()+"\",\""+datos.getseccion()+"\")");
    }

    
    }

        @Action
    public void cargandonit() throws SQLException {
    Statement st = contabilidad.getConnection().createStatement();
    Iterator it = listaRegistros.iterator();
    while (it.hasNext())
    {
        ponernit datos = (ponernit) it.next();
        st.executeUpdate("update alumno "
                + "set nit=\""+datos.getnit()+"\",nombrefact=\""+datos.getnombre()
                +"\",direccionfact=\""+datos.getdireccion()+"\" where id="+datos.getalumno());
    }

    
    }

                @Action
    public void cargandosolvente() throws SQLException {
    Statement st = contabilidad.getConnection().createStatement();
    Iterator it = listaRegistros.iterator();
    int control=0;
    while (it.hasNext())
    {
        ponernit datos = (ponernit) it.next();
        st.executeUpdate("update alumno "
                + "set mesespagados=3,inscrito=1,mora=0 where id="+datos.getalumno());
        System.out.println(control++ +" "+datos.getalumno()+" Solvente");
    }
    
    }

    @Action
    public void cargandotransaccion164() throws SQLException {
    Statement st = contabilidad.getConnection().createStatement();
    Iterator it = listaRegistros.iterator();
    while (it.hasNext())
    {
        transaccion164 datos = (transaccion164) it.next();
        st.executeUpdate("insert into transaccion164 "
                + "values("+datos.getboleta()+","+datos.getalumno()+",'"+datos.getFecha()
                +"',"+datos.getcolegiatura()+","+datos.getcomputacion()
                +","+datos.getingles()+","+datos.getlaboratorios()
                +","+datos.getotros()+","+datos.getmora()+")");
    }

    
    }

        @Action
    public void cargandotransaccion() throws SQLException {
    Statement st = contabilidad.getConnection().createStatement();
    Iterator it = listaRegistros.iterator();
    while (it.hasNext())
    {
        transaccion datos = (transaccion) it.next();
        st.executeUpdate("insert into transaccion "
                + "values("+datos.getboleta()+","+datos.getalumno()+",'"+datos.getFecha()+"',"+datos.gettipo()
                +","+datos.getinscripcion()+","+datos.getgacc()+","+datos.getgraduacion()+","+datos.getgaic()
                +","+datos.getcolegiatura()+","+datos.getcomputacion()
                +","+datos.getingles()+","+datos.getlaboratorios()+","+datos.getcursos()
                +","+datos.getotros()+","+datos.getmora()+")");
    }

    }

        public void carga(int mesespagados, double pagocarga, double computacion, double ingles, String alumno) throws SQLException {
 /*   Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost/contabilidad", "root", "worms");
    Statement st = conexion.createStatement();
    System.out.println("update alumno "
                + "set mesespagados="+mesespagados+",pagocarga=\""+pagocarga
                +"\",computacion=\""+computacion+"\",ingles=\""+ingles+"\" where id="+alumno);
    st.executeUpdate("update alumno "
                + "set mesespagados="+mesespagados+",pagocarga=\""+pagocarga
                +"\",computacion=\""+computacion+"\",ingles=\""+ingles+"\" where id="+alumno);
    
    conexion.close();*/
    }
        
        public void mesespagados(String alumno) throws SQLException{
    Statement st = contabilidad.getConnection().createStatement();
    Statement x=contabilidad.getConnection().createStatement();
    ResultSet consulta = x.executeQuery (getTable(alumno));


    st.executeUpdate("update alumno "
                + "set mesespagados="+getmeses(consulta,alumno)+" where id="+alumno);

    
    }

        public int getmeses(ResultSet consulta,String alumno) throws SQLException
    {
            int meses =0;

                    while (consulta.next())
                    {
                        fila = new Object[16];
                        for(int i=0;i<14;i++)
                        {
                            fila[i]=consulta.getString(i+1);
                        }
                        if(Double.parseDouble((String)fila[3])==0 && Double.parseDouble((String)fila[2])==0&& Double.parseDouble((String)fila[4])==0)
                        {
                            meses++;
                        fila[14]=descripcion(meses);
                        fila[15]=meses;

                        }
                        else if(Double.parseDouble((String)fila[3])==150 ||Double.parseDouble((String)fila[4])==995)
                        {
                            fila[14]=descripcion(11);
                            fila[15]=11;
                        }else if(Double.parseDouble((String)fila[2])>0)
                        {
                            fila[14]=descripcion(0);
                            fila[15]=0;
                        }

                        Statement x=contabilidad.getConnection().createStatement();
                        x.executeUpdate("UPDATE transaccion SET mes="+fila[15]+" WHERE id="+fila[1]+" AND alumno_id="+alumno);
                        
                    }





           return meses;
        }

    public int buscaralumno(int id) throws SQLException
    {
    Statement st = contabilidad.getConnection().createStatement();
    ResultSet valor =st.executeQuery("select id from alumno where id="+id);
    int tmp=0;
    while(valor.next())
            tmp=valor.getInt(1);
    return tmp;
    }

    @Action
    public void parsenadoAsignacion() throws IOException {
    listaRegistros.clear();
        CsvReader cvsReader = null;

       try {
       File fichero = new File("/home/anderson/Escritorio/conta20110323/asignacion.csv");
       FileReader freader = new FileReader(fichero);
      cvsReader = new CsvReader(freader,',');
       String[] headers = null;
      
      //int count=0;
     // Leemos las cabeceras del fichero (primera fila).
       if(cvsReader.readHeaders()) {
            headers = cvsReader.getHeaders();
            for(int i=0;i<headers.length;i=i+5)
            {
                asignacion registro = new asignacion();
                registro.setciclo(Integer.parseInt(headers[i]));
                registro.setalumno(Integer.parseInt(headers[i+1]));
                registro.setcarrera(headers[i+2]);
                registro.setgrado(headers[i+3]);
                registro.setseccion(headers[i+4]);
          //      count++;
                listaRegistros.add(registro);
            }
       }
      // Leemos los registros
       
       while(cvsReader.readRecord())
       {
           for(int i=0;i<headers.length;i=i+5)
           {
                asignacion registro = new asignacion();
                registro.setciclo(Integer.parseInt(cvsReader.get(headers[i])));
                registro.setalumno(Integer.parseInt(cvsReader.get(headers[i+1])));
                registro.setcarrera(cvsReader.get(headers[i+2]));
                registro.setgrado(cvsReader.get(headers[i+3]));
                registro.setseccion(cvsReader.get(headers[i+4]));
        //        count++;
                listaRegistros.add(registro);
            }
       }

       Iterator it = listaRegistros.iterator();
       int control=0;
	       while (it.hasNext()){
                    control++;
	            asignacion datos = (asignacion) it.next();
                    System.out.println(control+" "+datos.getciclo()+datos.getalumno()+datos.getcarrera()+datos.getgrado()+datos.getseccion());
	         }
    //   System.out.println(count+"="+control);
     
    } catch(Exception e) {
            
    }  finally {
        if(cvsReader!=null) {
            cvsReader.close();
        }
    }
    }

     @Action
    public void parsenadonit() throws IOException {
    listaRegistros.clear();
        CsvReader cvsReader = null;

       try {
       File fichero = new File("/home/anderson/Escritorio/conta20110323/NitAlumno.csv");
       FileReader freader = new FileReader(fichero);
      cvsReader = new CsvReader(freader,';');
       String[] headers = null;

      //int count=0;
     // Leemos las cabeceras del fichero (primera fila).
       if(cvsReader.readHeaders()) {
            headers = cvsReader.getHeaders();
            for(int i=0;i<headers.length;i=i+4)
            {
                ponernit registro = new ponernit();
                registro.setalumno(Integer.parseInt(headers[i]));
                registro.setnombre(headers[i+1]);
                registro.setnit(headers[i+2]);
                registro.setdireccion(headers[i+3]);
          //      count++;
                listaRegistros.add(registro);
            }
       }
      // Leemos los registros

       while(cvsReader.readRecord())
       {
           for(int i=0;i<headers.length;i=i+4)
           {
                ponernit registro = new ponernit();
                registro.setalumno(Integer.parseInt(cvsReader.get(headers[i])));
                registro.setnombre(cvsReader.get(headers[i+1]));
                registro.setnit(cvsReader.get(headers[i+2]));
                registro.setdireccion(cvsReader.get(headers[i+3]));
        //        count++;
                listaRegistros.add(registro);
            }
       }

       Iterator it = listaRegistros.iterator();
       int control=0;
	       while (it.hasNext()){
                    control++;
	            ponernit datos = (ponernit) it.next();
                    System.out.println(control+" "+datos.getalumno()+datos.getnombre()+datos.getnit()+datos.getdireccion());
	         }
    //   System.out.println(count+"="+control);

    } catch(Exception e) {

    }  finally {
        if(cvsReader!=null) {
            cvsReader.close();
        }
    }
    }

     @Action
    public void parsenadosolvente() throws IOException {
    listaRegistros.clear();
        CsvReader cvsReader = null;

       try {
       File fichero = new File("/home/anderson/Escritorio/conta20110323/solvente.csv");
       FileReader freader = new FileReader(fichero);
      cvsReader = new CsvReader(freader,';');
       String[] headers = null;

      //int count=0;
     // Leemos las cabeceras del fichero (primera fila).
       if(cvsReader.readHeaders()) {
            headers = cvsReader.getHeaders();
            for(int i=0;i<headers.length;i++)
            {
                ponernit registro = new ponernit();
                registro.setalumno(Integer.parseInt(headers[i]));
          //      count++;
                listaRegistros.add(registro);
            }
       }
      // Leemos los registros

       while(cvsReader.readRecord())
       {
           for(int i=0;i<headers.length;i=i+4)
           {
                ponernit registro = new ponernit();
                registro.setalumno(Integer.parseInt(cvsReader.get(headers[i])));
        //        count++;
                listaRegistros.add(registro);
            }
       }

       Iterator it = listaRegistros.iterator();
       int control=0;
	       while (it.hasNext()){
                    control++;
	            ponernit datos = (ponernit) it.next();
                    System.out.println(control +" "+datos.getalumno());
	         }
    //   System.out.println(count+"="+control);

    } catch(Exception e) {

    }  finally {
        if(cvsReader!=null) {
            cvsReader.close();
        }
    }
    }


    
    @Action
    public void parsenadoTransaccion164() throws IOException {
    listaRegistros.clear();
        CsvReader cvsReader = null;

       try {
       File fichero = new File("/home/anderson/Escritorio/conta20110323/transaccion164.csv");
       FileReader freader = new FileReader(fichero);
      cvsReader = new CsvReader(freader,',');
       String[] headers = null;
      
      //int count=0;
     // Leemos las cabeceras del fichero (primera fila).
       if(cvsReader.readHeaders()) {
            headers = cvsReader.getHeaders();
            for(int i=0;i<headers.length;i=i+9)
            {
                transaccion164 registro = new transaccion164();
                registro.setboleta(Integer.parseInt(headers[i]));
                registro.setalumno(Integer.parseInt(headers[i+1]));
                registro.setfecha(headers[i+2]);
                registro.setcolegiatura(Double.parseDouble(headers[i+3]));
                registro.setcomputacion(Double.parseDouble(headers[i+4]));
                registro.setingles(Double.parseDouble(headers[i+5]));
                registro.setlaboratorios(Double.parseDouble(headers[i+6]));
                registro.setotros(Double.parseDouble(headers[i+7]));
                registro.setmora(Double.parseDouble(headers[i+8]));
          //      count++;
                if(buscaralumno(Integer.parseInt(headers[i+1]))!=0)
                listaRegistros.add(registro);
            }
       }
      // Leemos los registros
       
       while(cvsReader.readRecord())
       {
           for(int i=0;i<headers.length;i=i+9)
           {
                 transaccion164 registro = new transaccion164();
                registro.setboleta(Integer.parseInt(cvsReader.get(headers[i])));
                registro.setalumno(Integer.parseInt(cvsReader.get(headers[i+1])));
                registro.setfecha(cvsReader.get(headers[i+2]));
                registro.setcolegiatura(Double.parseDouble(cvsReader.get(headers[i+3])));
                registro.setcomputacion(Double.parseDouble(cvsReader.get(headers[i+4])));
                registro.setingles(Double.parseDouble(cvsReader.get(headers[i+5])));
                registro.setlaboratorios(Double.parseDouble(cvsReader.get(headers[i+6])));
                registro.setotros(Double.parseDouble(cvsReader.get(headers[i+7])));
                registro.setmora(Double.parseDouble(cvsReader.get(headers[i+8])));
          //      count++;
                if(buscaralumno(Integer.parseInt(cvsReader.get(headers[i+1])))!=0)
                    listaRegistros.add(registro);
            }
       }

       Iterator it = listaRegistros.iterator();
       int control=0;
	       while (it.hasNext()){
                    control++;
	            transaccion164 datos = (transaccion164) it.next();
                    System.out.println(control+" "+datos.getboleta()+" "+datos.getalumno()+" "+datos.getFecha()+" "+datos.getcolegiatura()
                            +" "+datos.getcomputacion()+" "+datos.getingles()+" "+datos.getlaboratorios()+" "+datos.getotros()+" "+datos.getmora());
	         }
    //   System.out.println(count+"="+control);
     
    } catch(Exception e) {
            
    }  finally {
        if(cvsReader!=null) {
            cvsReader.close();
        }
    }
    }

    @Action
    public void parsenadoTransaccion() throws IOException {
    listaRegistros.clear();
        CsvReader cvsReader = null;

       try {
       File fichero = new File("/home/anderson/Escritorio/conta20110323/transaccion.csv");
       FileReader freader = new FileReader(fichero);
      cvsReader = new CsvReader(freader,';');
       String[] headers = null;

      //int count=0;
     // Leemos las cabeceras del fichero (primera fila).
       if(cvsReader.readHeaders()) {
            headers = cvsReader.getHeaders();
            for(int i=0;i<headers.length;i=i+15)
            {
                transaccion registro = new transaccion();
                registro.setboleta(Integer.parseInt(headers[i]));
                registro.setalumno(Integer.parseInt(headers[i+1]));
                registro.setfecha(headers[i+2]);
                registro.settipo(Integer.parseInt(headers[i+3]));
                registro.setinscripcion(Double.parseDouble(headers[i+4]));
                registro.setgacc(Double.parseDouble(headers[i+5]));
                registro.setgraduacion(Double.parseDouble(headers[i+6]));
                registro.setgaic(Double.parseDouble(headers[i+7]));
                registro.setcolegiatura(Double.parseDouble(headers[i+8]));
                registro.setcomputacion(Double.parseDouble(headers[i+9]));
                registro.setingles(Double.parseDouble(headers[i+10]));
                registro.setlaboratorios(Double.parseDouble(headers[i+11]));
                registro.setcursos(Double.parseDouble(headers[i+12]));
                registro.setotros(Double.parseDouble(headers[i+13]));
                registro.setmora(Double.parseDouble(headers[i+14]));
          //      count++;
                if(buscaralumno(Integer.parseInt(headers[i+1]))!=0)
                listaRegistros.add(registro);
            }
       }
      // Leemos los registros

       while(cvsReader.readRecord())
       {
           for(int i=0;i<headers.length;i=i+15)
           {
                 transaccion registro = new transaccion();
                registro.setboleta(Integer.parseInt(cvsReader.get(headers[i])));
                registro.setalumno(Integer.parseInt(cvsReader.get(headers[i+1])));
                registro.setfecha(cvsReader.get(headers[i+2]));
                registro.settipo(Integer.parseInt(cvsReader.get(headers[i+3])));
                registro.setinscripcion(Double.parseDouble(cvsReader.get(headers[i+4])));
                registro.setgacc(Double.parseDouble(cvsReader.get(headers[i+5])));
                registro.setgraduacion(Double.parseDouble(cvsReader.get(headers[i+6])));
                registro.setgaic(Double.parseDouble(cvsReader.get(headers[i+7])));
                registro.setcolegiatura(Double.parseDouble(cvsReader.get(headers[i+8])));
                registro.setcomputacion(Double.parseDouble(cvsReader.get(headers[i+9])));
                registro.setingles(Double.parseDouble(cvsReader.get(headers[i+10])));
                registro.setlaboratorios(Double.parseDouble(cvsReader.get(headers[i+11])));
                registro.setcursos(Double.parseDouble(cvsReader.get(headers[i+12])));
                registro.setotros(Double.parseDouble(cvsReader.get(headers[i+13])));
                registro.setmora(Double.parseDouble(cvsReader.get(headers[i+14])));
          //      count++;
                if(buscaralumno(Integer.parseInt(cvsReader.get(headers[i+1])))!=0)
                    listaRegistros.add(registro);
            }
       }

       Iterator it = listaRegistros.iterator();
       int control=0;
	       while (it.hasNext()){
                    control++;
	            transaccion datos = (transaccion) it.next();
                    System.out.println(control+" "+datos.getboleta()+" "+datos.getalumno()+" "+datos.getFecha()
                            +" "+datos.gettipo()+" "+datos.getinscripcion()+" "+datos.getgacc()+" "+datos.getgraduacion()
                            +" "+datos.getgaic()+" "+datos.getcolegiatura()+" "+datos.getcomputacion()
                            +" "+datos.getingles()+" "+datos.getlaboratorios()+" "+datos.getcursos()
                            +" "+datos.getotros()+" "+datos.getmora());
	         }
    //   System.out.println(count+"="+control);

    } catch(Exception e) {

    }  finally {
        if(cvsReader!=null) {
            cvsReader.close();
        }
    }

    }
    







    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTree jTree1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;

    private void actualizarArbol() throws SQLException {
                        DefaultMutableTreeNode root=new DefaultMutableTreeNode("Ciclo Académico 2011");
        DefaultMutableTreeNode grado,carrera,seccion,alumno;
        Statement s = contabilidad.getConnection().createStatement();
        Statement t = contabilidad.getConnection().createStatement();
        Statement u = contabilidad.getConnection().createStatement();
        Statement v = contabilidad.getConnection().createStatement();
        Statement w = contabilidad.getConnection().createStatement();
        ResultSet getgrado = s.executeQuery ("SELECT DISTINCT g.nombre,g.id "
                +"FROM carrera c, grado g, seccion s, asignacion asi "
                +"WHERE asi.carrera_id = c.id "
                +"AND asi.grado_id = g.id "
                +"AND asi.seccion_id = s.id "
                +"ORDER BY c.id, g.id, s.id");
        while (getgrado.next())
        {
            grado = new DefaultMutableTreeNode (getgrado.getString (1));
           root.add(grado);
            ResultSet getcarrera = t.executeQuery ("SELECT DISTINCT c.nombre,c.id "
                +"FROM carrera c, grado g, seccion s, asignacion asi "
                +"WHERE asi.carrera_id = c.id "
                +"AND asi.grado_id = g.id "
                +"AND asi.seccion_id = s.id "
                +"AND g.id=\""+getgrado.getString(2)+"\"");
            while (getcarrera.next())
            {
                carrera = new DefaultMutableTreeNode (getcarrera.getString (1));
              grado.add(carrera);
                ResultSet getseccion = u.executeQuery ("SELECT DISTINCT s.nombre,s.id "
                +"FROM carrera c, grado g, seccion s, asignacion asi "
                +"WHERE asi.carrera_id = c.id "
                +"AND asi.grado_id = g.id "
                +"AND asi.seccion_id = s.id "
                +"AND g.id=\""+getgrado.getString(2)+"\""
                +"AND c.id=\""+getcarrera.getString(2)+"\"");
            while (getseccion.next())
            {
                seccion = new DefaultMutableTreeNode (getseccion.getString (1));
              carrera.add(seccion);
                 ResultSet getalumno = v.executeQuery ("SELECT DISTINCT a.id, a.apellido, a.mesespagados "
                +"FROM carrera c, grado g, seccion s, asignacion asi, alumno a "
                +"WHERE asi.carrera_id = c.id "
                +"AND asi.grado_id = g.id "
                +"AND asi.seccion_id = s.id "
                +"AND asi.alumno_id = a.id "
                +"AND g.id=\""+getgrado.getString(2)+"\""
                +"AND c.id=\""+getcarrera.getString(2)+"\""
                +"AND s.id=\""+getseccion.getString(2)+"\""
                +"ORDER by a.apellido");
            while (getalumno.next())
            {
                //if(getalumno.getInt(3)<3)
                //{
                    alumno = new DefaultMutableTreeNode ("<HTML> "+getalumno.getString (1)+" "+getalumno.getString(2)+" <FONT COLOR=\"red\">"+getgrado.getString(2)+" "+getcarrera.getString(1)+"</FONT></HTML>");
                    seccion.add(alumno);
               //     mesespagados(getalumno.getString (1));
                //}
            }
            }
            }
        }

        



        DefaultTreeModel treeModel = new DefaultTreeModel(root);
        jTree1.setModel(treeModel);
        
        MouseListener ml = new MouseAdapter()
        {
            @Override
            public void mousePressed(MouseEvent e)
            {
                jButton1.setEnabled(false);
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                contador=0;
                // Se obtiene el path para esa fila. Con el path podemos obtener
                // los nodos.
                TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY());
                try
                {
                    StringTokenizer st = new StringTokenizer(selPath.getLastPathComponent().toString());
                    String tmp=st.nextToken();
                    if(tmp.startsWith("<HTML>"))
                    {
                        tmp=st.nextToken();
                        alumnoUpdate=tmp;
                        modeloTabla.getDataVector().clear();
                    Statement s = contabilidad.getConnection().createStatement();
                    ResultSet consulta = s.executeQuery (getTable(tmp));
                    Tabla(consulta);
                }
                }
                catch(Exception j){}
            }
        };
        jTree1.addMouseListener(ml);

                KeyListener kl = new KeyAdapter()
        {
            @Override
            public void keyReleased(KeyEvent e)
            {
                if(e.getKeyCode()==KeyEvent.VK_UP||e.getKeyCode()==KeyEvent.VK_DOWN)
                {
                jButton1.setEnabled(false);
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                contador=0;
                // Se obtiene el path para esa fila. Con el path podemos obtener
                // los nodos.
                TreePath selPath = jTree1.getSelectionPath();
                try
                {
                    StringTokenizer st = new StringTokenizer(selPath.getLastPathComponent().toString());
                    String tmp=st.nextToken();
                    if(tmp.startsWith("<HTML>"))
                    {
                        tmp=st.nextToken();
                        alumnoUpdate=tmp;
                        //System.out.print(alumnoUpdate+" ");
                        modeloTabla.getDataVector().clear();
                    
                    Statement s = contabilidad.getConnection().createStatement();
                    ResultSet consulta = s.executeQuery (getTable(tmp));
                    Tabla(consulta);
                    
                }
                }
                catch(Exception j){}

                }
            }
        };
              jTree1.addKeyListener(kl);

    }

    String getTable(String alumno)
    {
        String query="SELECT t.fecha 'Fecha', t.id 'Código', "//+"a.apellido 'Apellidos', "
                            //+"a.nombre 'Nombres', g.nombre 'Grado', c.nombre 'Carrera', s.nombre 'Seccion', "
                            +"t.inscripcion 'Inscripción', "
                            +"t.gacc 'GACC', t.graduacion 'Graduación', t.gaic 'GAIC', t.colegiatura 'Colegiatura', t.computacion 'Computación', "
                            +"t.ingles 'Inglés', t.laboratorios 'Laboratorios', t.cursos 'Cursos', t.otros 'Otros', t.mora 'Mora', "
                            +"(t.inscripcion + t.gaic + t.colegiatura + t.computacion + t.ingles + t.laboratorios + t.cursos + t.otros + t.mora + t.gacc + t.graduacion) 'Total Pagado' "
                            +"FROM alumno a, grado g, carrera c, seccion s, asignacion asi, transaccion t "
                            +"WHERE asi.alumno_id = a.id "
                            +"AND asi.grado_id = g.id "
                            +"AND asi.seccion_id = s.id "
                            +"AND asi.carrera_id = c.id "
                            +"AND t.alumno_id = a.id "
                            +"AND t.alumno_id ="+alumno+" "
                            +"ORDER BY t.fecha,t.id ";

        return query;
    }

        String replace(String id,String alumno,String fecha)
    {
        String query="REPLACE INTO transaccion(id,alumno_id,ciclo,fecha,tipo)"
                +"VALUES(\""+id+"."+contador+"\","+alumno+",2011,\""+fecha+"\",164)";

        return query;
    }

    @Action
    public void Actualizar() throws SQLException {
        jButton1.setEnabled(false);
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
            Statement s = contabilidad.getConnection().createStatement();
    Statement t = contabilidad.getConnection().createStatement();
   /* if(jTextField1.getText()!=null || !jTextField1.getText().equals(""))
     //   st.executeUpdate("update alumno "
       //         + "set mesespagados="+jTextField1.getText()+",inscrito=1 where id="+alumnoUpdate);
    // jTextField1.setText(null);
    conexion.close();
    modeloTabla.getDataVector().clear();
    fila = new Object[14];
    modeloTabla.addRow(fila);
    actualizarArbol();*/

    for(int i=0;i<modeloTabla.getRowCount();i++)
    {
        Object up[] = new Object[15];

        for(int j=0;j<modeloTabla.getColumnCount()-1;j++)
        {
           if(modeloTabla.getValueAt(i, j)==null || modeloTabla.getValueAt(i, j).equals(""))
               up[j]=0;
           else
               up[j]=modeloTabla.getValueAt(i, j);
        }
        System.out.println("REPLACE INTO transaccion VALUES("
                +"\""+up[1]+"\","+alumnoUpdate+",2011,\""+up[0]+"\",164,"
                +"\""+up[2]+"\","+up[3]+","+up[4]+","+up[5]+","+up[6]
                +","+up[7]+","+up[8]+","+up[9]+","+up[10]+","+up[11]+","+up[12]+")");
        t.executeUpdate("REPLACE INTO transaccion VALUES("
                +"\""+up[1]+"\","+alumnoUpdate+",2011,\""+up[0]+"\",164,"
                +"\""+up[2]+"\","+up[3]+","+up[4]+","+up[5]+","+up[6]
                +","+up[7]+","+up[8]+","+up[9]+","+up[10]+","+up[11]+","+up[12]+")");
    }




    modeloTabla.getDataVector().clear();
                    ResultSet consulta = s.executeQuery (getTable(alumnoUpdate));
                    int meses =0;
                    while (consulta.next())
                    {
                        fila = new Object[15];
                        for(int i=0;i<14;i++)
                        {
                            fila[i]=consulta.getString(i+1);
                        }
                        fila[14]=descripcion(meses);
                        modeloTabla.addRow(fila);
                        meses++;
                    }
    
    fresh(modeloTabla.getRowCount());
    }

    @Action
    public void addRow() {
        contador++;
                        jButton1.setEnabled(false);
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                try
                {

                    Statement s = contabilidad.getConnection().createStatement();
                    Statement t = contabilidad.getConnection().createStatement();
                    t.executeUpdate(replace((String)modeloTabla.getValueAt(columnaActual, 1),alumnoUpdate,(String)modeloTabla.getValueAt(columnaActual, 0)));
                    modeloTabla.getDataVector().clear();
                    ResultSet consulta = s.executeQuery (getTable(alumnoUpdate));

                    int meses =0;
                    while (consulta.next())
                    {
                        fila = new Object[15];
                        for(int i=0;i<14;i++)
                        {
                            fila[i]=consulta.getString(i+1);
                        }
                        fila[14]=descripcion(meses);
                        modeloTabla.addRow(fila);
                        meses++;
                    }               
                }
                catch(Exception j){}
                fresh(modeloTabla.getRowCount());
    }

    @Action
    public void delRow() {
        String tmp="";
        for(int i=0;i<modeloTabla.getColumnCount();i++)
            tmp+=" "+modeloTabla.getValueAt(columnaActual, i);

        int confirmado = JOptionPane.showConfirmDialog(
   null,
   "¿Seguro que quiers borra la Fila:?\n"+tmp+" '\n¡ADVERTENCIA NO SE PODRA DESHACER ESTA OPERACIÓN!");

if (JOptionPane.OK_OPTION == confirmado)
{
    jButton1.setEnabled(false);
                jButton2.setEnabled(false);
                jButton3.setEnabled(false);
                try
                {

                    Statement s = contabilidad.getConnection().createStatement();
                    Statement t = contabilidad.getConnection().createStatement();
                    t.executeUpdate("DELETE FROM transaccion WHERE id=\""+(String)modeloTabla.getValueAt(columnaActual, 1)+"\""
                            +"AND alumno_id="+alumnoUpdate);
                    modeloTabla.getDataVector().clear();
                    ResultSet consulta = s.executeQuery (getTable(alumnoUpdate));
                    int meses =0;
                    while (consulta.next())
                    {
                        fila = new Object[15];
                        for(int i=0;i<14;i++)
                        {
                            fila[i]=consulta.getString(i+1);
                        }
                        fila[14]=descripcion(meses);
                        modeloTabla.addRow(fila);
                        meses++;
                    }

                }
                catch(Exception j){}
}
else
   System.out.println("vale... no borro nada...");

fresh(modeloTabla.getRowCount());

    }

    void fresh(int meses){
    if(meses>2)
        jLabel1.setText("<HTML><FONT COLOR=\"green\">"
                +meses+" meses pagados SOLVENTE "+descripcion(meses)+"</FONT></HTML>");
    else
        jLabel1.setText("<HTML><FONT COLOR=\"red\">"
                +meses+" meses pagados INSOLVENTE "+descripcion(meses)+"</FONT></HTML>");
    }

    String descripcion(int clave)
    {
        switch(clave)
        {
            case 0:
            {
                return "Inscripción";
            }
            case 1:
            {
             return "Enero";
            }
            case 2:
            {
                return "Febrero";
            }
            case 3:
            {
                return "Marzo";
            }
            case 4:
            {
                return "Abril";
            }
            case 5:
            {
                return "Mayo";
            }
            case 6:
            {
                return "Junio";
            }
            case 7:
            {
                return "Julio";
            }
            case 8:
            {
                return "Agosto";
            }
            case 9:
            {
                return "Septiebre";
            }
            case 10:
            {
                return "Octubre";
            }
            case 11:
            {
                return "GACC";
            }
        }
        return null;
    }

    void Tabla(ResultSet consulta) throws SQLException
    {
        int meses =0;
                    double pagocarga=0;
                    double computacion=0;
                    double ingles=0;
                    while (consulta.next())
                    {
                        fila = new Object[15];
                        for(int i=0;i<14;i++)
                        {
                            fila[i]=consulta.getString(i+1);
                        }
                        if(Double.parseDouble((String)fila[3])==0 && Double.parseDouble((String)fila[2])==0&& Double.parseDouble((String)fila[4])==0)
                        {
                            meses++;
                        fila[14]=descripcion(meses);
                        modeloTabla.addRow(fila);
                        pagocarga=Double.parseDouble((String)fila[6]);
                        computacion=Double.parseDouble((String)fila[7]);
                        ingles=Double.parseDouble((String)fila[8]);
                        
                        }
                        else if(Double.parseDouble((String)fila[3])==150 ||Double.parseDouble((String)fila[4])==995)
                        {
                            fila[14]=descripcion(11);
                            modeloTabla.addRow(fila);
                        }else if(Double.parseDouble((String)fila[2])>0)
                        {
                            fila[14]=descripcion(0);
                            modeloTabla.addRow(fila);
                        }
                    }



                    fresh(meses);
                    carga(meses,pagocarga,computacion,ingles,alumnoUpdate);
    }


}
